﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.events.*;
    import Engine.Helpers.*;
    import Display.DialogUI.*;
    import Classes.util.*;
    import Classes.effects.*;
    import Display.*;

    public class DockHouse extends MapResource {

        private static const NUM_FREEBIE_DOCKS:int = 2;
        private static const LINKED_OBJECT_TEMP_ID_START:Number = 70000;

        protected const STATE_STATIC:String = "static";
        private const DOCK_HOUSE:String = "dock_house";

        public function DockHouse(_arg1:String){
            super(_arg1);
            m_objectType = WorldObjectTypes.DOCK_HOUSE;
            setState(this.STATE_STATIC);
            m_typeName = this.DOCK_HOUSE;
        }
        override public function isSellable():Boolean{
            return (true);
        }
        override public function onBuildingConstructionCompleted_PreServerUpdate():void{
            this.initialize();
        }
        override public function canBeRotated():Boolean{
            return (false);
        }
        protected function initialize():void{
            var _local8:Dock;
            var _local1:Vector3 = getPosition();
            var _local2:Number = LINKED_OBJECT_TEMP_ID_START;
            var _local3:int;
            while (_local3 < NUM_FREEBIE_DOCKS) {
                _local8 = new Dock("dock_piece");
                _local1.x = (_local1.x - 2);
                _local8.setPosition(_local1.x, _local1.y);
                _local8.setId(_local2);
                _local8.setOuter(Global.world);
                _local8.conditionallyReattach();
                _local2 = (_local2 + 1);
                _local3++;
            };
            _local1 = getPosition();
            var _local4:HarvestableShip = new HarvestableShip("ship_cruise");
            _local4.setPosition((_local1.x - 4), (_local1.y + 2));
            _local4.setId(_local2);
            _local4.setOuter(Global.world);
            _local4.conditionallyReattach();
            _local4.setPlantedWhenShipArrives();
            var _local5:String = ZLoc.t("Dialogs", "CruiseUnlocked_message");
            var _local6 = "CruiseUnlocked";
            var _local7:CharacterDialog = new CharacterDialog(_local5, _local6, GenericDialogView.TYPE_OK, null, null, true, "assets/dialogs/cruise_guy.png");
            UI.displayPopup(_local7);
        }
        private function fireZeMissiles(_arg1:Event=null):void{
            var rofls:* = null;
            var e = _arg1;
            Sounds.play("cruise_fireworks");
            rofls = (this as MapResource);
            MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 300);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 500);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 700);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 900);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 1000);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 1200);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 1600);
            TimerUtil.callLater(function ():void{
                MapResourceEffectFactory.createEffect(rofls, EffectType.FIREWORK_BALLOONS);
            }, 1300);
        }
        override public function onSell():void{
            var _local2:MapResource;
            super.onSell();
            var _local1:Array = new Array();
            _local1 = _local1.concat(Global.world.getObjectsByClass(Dock));
            _local1 = _local1.concat(Global.world.getObjectsByClass(HarvestableShip));
            for each (_local2 in _local1) {
                _local2.detach();
                _local2.cleanUp();
            };
        }
        override public function checkPlacementRequirements(_arg1:int, _arg2:int):Boolean{
            var _local3:Boolean;
            if ((((((_arg2 < -20)) && ((_arg1 > -25)))) || ((_arg1 > 0)))){
                return (false);
            };
            return (super.checkPlacementRequirements(_arg1, _arg2));
        }

    }
}//package Classes 
